/*
 * <one line to give the program's name and a brief idea of what it does.>
 * Copyright (C) 2019
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef DATABASE_H
#define DATABASE_H

#include "commondata.hpp"
#include <vector>

/**
 * \class DataBase
 * This class is abstract only. Basic class for various type databases
 */
class DataBase {
public:
	DataBase() {}
	DataBase(const DataBase & other) = delete;
	virtual ~DataBase() {}

	/**
	 * Store data to database
	 * \param[in] data pointer to data we must store
	 * \param[in] size data size
	 */
	virtual void put(void * data, const std::size_t & size) = 0;

	/**
	 * Receive data from database
	 * \param[out] data pointer to data where we store result
	 * \param[in] size data size
	 * \return true if we get data, false if not
	 */
	virtual bool get(void * data, const std::size_t & size) = 0;

	/**
	 * How many records in database
	 * \return count of records
	 */
	virtual std::size_t size() = 0;

	/**
	 * Check if database have any record
	 * \return true if we have 1 or more records, false if no
	 */
	virtual bool empty() = 0;

	/**
	 * Delete all records from database
	 */
	virtual void erase() = 0;

	/**
	 * add new build to database
	 * \param[in] data vector with new potential builds for computing
	 * \param[in] build already calculated build, just store in database
	 * \param[out] queue Database for new builds
	 * \return amount of new builds in database
	 */
	virtual std::size_t addBuilds(std::vector< PathData > * data, PathData * build, DataBase * queue) = 0;

	/**
	 * Update build in database
	 * \param[in] data player build
	 * \return true if build updated, or false if not
	 */
	virtual bool updateBuild(PathData * data) = 0;
};

#endif // DATABASE_H
